/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_USUA_SIST")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbUsuaSist.findAll", query = "SELECT a FROM AmTbUsuaSist a"),
    @NamedQuery(name = "AmTbUsuaSist.findByCdUsua", query = "SELECT a FROM AmTbUsuaSist a WHERE a.cdUsua = :cdUsua"),
    @NamedQuery(name = "AmTbUsuaSist.findByNmEmaiUsua", query = "SELECT a FROM AmTbUsuaSist a WHERE a.nmEmaiUsua = :nmEmaiUsua"),
    @NamedQuery(name = "AmTbUsuaSist.findByDtUltiAces", query = "SELECT a FROM AmTbUsuaSist a WHERE a.dtUltiAces = :dtUltiAces"),
    @NamedQuery(name = "AmTbUsuaSist.findByDtCada", query = "SELECT a FROM AmTbUsuaSist a WHERE a.dtCada = :dtCada")})
public class AmTbUsuaSist implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_USUA")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_USUA_SIST")
    @SequenceGenerator(name="seq_AM_TB_USUA_SIST", sequenceName = "seq_AM_TB_USUA_SIST")
    private Integer cdUsua;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "NM_EMAI_USUA")
    private String nmEmaiUsua;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DT_ULTI_ACES")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtUltiAces;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DT_CADA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtCada;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "amTbUsuaSist")
    private Collection<AmTbUsuaSistMedi> amTbUsuaSistMediCollection;
    @JoinColumn(name = "CD_TIPO_USUA", referencedColumnName = "CD_TIPO_USUA")
    @ManyToOne(optional = false)
    private AmTbTipoUsua cdTipoUsua;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cdUsua")
    private Collection<AmTbLogAces> amTbLogAcesCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "amTbUsuaSist")
    private AmTbPaci amTbPaci;

    public AmTbUsuaSist() {
    }

    public AmTbUsuaSist(Integer cdUsua) {
        this.cdUsua = cdUsua;
    }

    public AmTbUsuaSist(Integer cdUsua, String nmEmaiUsua, Date dtUltiAces, Date dtCada) {
        this.cdUsua = cdUsua;
        this.nmEmaiUsua = nmEmaiUsua;
        this.dtUltiAces = dtUltiAces;
        this.dtCada = dtCada;
    }

    public Integer getCdUsua() {
        return cdUsua;
    }

    public void setCdUsua(Integer cdUsua) {
        this.cdUsua = cdUsua;
    }

    public String getNmEmaiUsua() {
        return nmEmaiUsua;
    }

    public void setNmEmaiUsua(String nmEmaiUsua) {
        this.nmEmaiUsua = nmEmaiUsua;
    }

    public Date getDtUltiAces() {
        return dtUltiAces;
    }

    public void setDtUltiAces(Date dtUltiAces) {
        this.dtUltiAces = dtUltiAces;
    }

    public Date getDtCada() {
        return dtCada;
    }

    public void setDtCada(Date dtCada) {
        this.dtCada = dtCada;
    }

    @XmlTransient
    public Collection<AmTbUsuaSistMedi> getAmTbUsuaSistMediCollection() {
        return amTbUsuaSistMediCollection;
    }

    public void setAmTbUsuaSistMediCollection(Collection<AmTbUsuaSistMedi> amTbUsuaSistMediCollection) {
        this.amTbUsuaSistMediCollection = amTbUsuaSistMediCollection;
    }

    public AmTbTipoUsua getCdTipoUsua() {
        return cdTipoUsua;
    }

    public void setCdTipoUsua(AmTbTipoUsua cdTipoUsua) {
        this.cdTipoUsua = cdTipoUsua;
    }

    @XmlTransient
    public Collection<AmTbLogAces> getAmTbLogAcesCollection() {
        return amTbLogAcesCollection;
    }

    public void setAmTbLogAcesCollection(Collection<AmTbLogAces> amTbLogAcesCollection) {
        this.amTbLogAcesCollection = amTbLogAcesCollection;
    }

    public AmTbPaci getAmTbPaci() {
        return amTbPaci;
    }

    public void setAmTbPaci(AmTbPaci amTbPaci) {
        this.amTbPaci = amTbPaci;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdUsua != null ? cdUsua.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbUsuaSist)) {
            return false;
        }
        AmTbUsuaSist other = (AmTbUsuaSist) object;
        if ((this.cdUsua == null && other.cdUsua != null) || (this.cdUsua != null && !this.cdUsua.equals(other.cdUsua))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbUsuaSist[ cdUsua=" + cdUsua + " ]";
    }
    
}
